package com.yanqu.road.server.cmd.palace;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.estatewar.EstateWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.user.CrossUserNotifyMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_PALACE_PLAYER_INFO_SYNC, desc = "玩家信息同步")
public class CrossPalacePlayerSyncCmd extends CrossCommand {
    private int activityId;
    private long userId;
    private UserBaseInfo userInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        EstateWarProto.PalacePlayerSyncMsg reqMsg = EstateWarProto.PalacePlayerSyncMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = reqMsg.getUserId();
        userInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerBaseData());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossUserNotifyMgr.notifyReload(userInfo, userId);
    }

    @Override
    public void sendData() {

    }
}
